home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Microsoft Multimedia Viewer How-To CD
/
Microsoft Multimedia Viewer How-To CD.iso
/
mvsample
/
progsamp
/
eplist
/
parse.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-03-21
|
3KB
|
146 lines
#include <windows.h>
#include <ctype.h>
#include <stdlib.h>
#include <viewer.h>
#include "eplist.h"
#include "parse.h"
LPSTR EatWhite(LPSTR lpsz)
{
while(*lpsz && *lpsz == ' ')
lpsz++;
return lpsz;
}
LPSTR MakeInt(LPSTR lpsz, LPINT lpi)
{
BOOL bNeg = FALSE;
if(*lpsz == '-')
{
bNeg = TRUE;
lpsz++;
}
for(*lpi = 0; isdigit(*lpsz); lpsz++)
*lpi = *lpi * 10 + (*lpsz - '0');
if(bNeg)
*lpi *= -1;
return lpsz;
}
LPSTR MakeWord(LPSTR lpsz, LPSTR lpszWord)
{
char chTerm;
if(*lpsz == '"')
{
chTerm = '"';
lpsz++;
}
else
{
chTerm = ' ';
}
while(*lpsz && *lpsz != chTerm)
{
*lpszWord++ = *lpsz++;
}
*lpszWord = 0;
if(chTerm == '"' && *lpsz)
return ++lpsz;
else
return lpsz;
}
/*************************************************************************
* CopyFilename: Copies an MVB filename string and converts backslashes
* to forward slashes. This makes the filename compatible
* with Viewer commands.
*
*************************************************************************/
void CopyFilename(
LPSTR lpszDest,
LPSTR lpszSrc)
{
int i, j;
for(i = 0, j = 0; lpszSrc[i]; i++)
{
switch(lpszSrc[i])
{
case ' ':
break;
case '\\':
lpszDest[j++] = '/';
break;
default:
lpszDest[j++] = lpszSrc[i];
break;
}
}
lpszDest[j] = 0;
}
int ParseAuthorString(LPLISTINFO lpLI, LPSTR lpszAuthor)
{
// Parse author-data string and record pane settings
lstrcpy(lpLI->szAuthorData, lpszAuthor);
lpszAuthor = MakeWord(EatWhite(lpszAuthor), lpLI->szListFilename);
while(*lpszAuthor)
{
lpszAuthor = EatWhite(lpszAuthor);
if(*lpszAuthor == '/')
lpszAuthor++;
else
break;
switch(*lpszAuthor)
{
case 'W': case 'w':
lpszAuthor = MakeInt(++lpszAuthor, &lpLI->iWidth);
break;
case 'H': case 'h':
// lpszAuthor = MakeInt(++lpszAuthor, &lpLI->iLines);
lpszAuthor = MakeInt(++lpszAuthor, &lpLI->iHeight);
break;
case 'f': case 'F':
lpszAuthor = MakeWord(++lpszAuthor, lpLI->szFont);
break;
case 's': case 'S':
lpszAuthor = MakeInt(++lpszAuthor, &lpLI->iFontSize);
break;
default:
return LISTERR_SYNTAX;
}
}
return 0;
}